package com.lsy.on_line.zaixian.mapper;

import com.lsy.on_line.zaixian.model.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ShiYuan
 * @since 2022-07-24
 */
public interface OrderMapper extends BaseMapper<Order> {

    /**
     * 查询用户是否购买过商品
     * @param userId
     * @param videoId
     * @param state
     * @return
     */
    Order findByUserIdAndVideoIdAndState(@Param("user_id") int userId,@Param("video_id") int videoId,@Param("state") int state);

    /**
     * 下单
     * @return
     */
    int saveOrder(Order order);

    /**
     * 根据userId获取订单列表
     * @param userId
     * @return
     */
    List<Order> findOrderListBuUserId(@Param("user_id") Integer userId);
}
